//
//  PersonalDataVC.m
//  PlayShow
//
//  Created by hff on 2018/4/23.
//  Copyright © 2018年 threeTi. All rights reserved.
//

#import "PersonalDataVC.h"
#import "UIColor+Utils.h"
#import "AppMacro.h"
#import "HUD.h"
#import "PersonalDataCell.h"

@interface PersonalDataVC ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *listTableView;//课程列表
@property (strong, nonatomic) NSMutableArray *dataArray;//数据
@property (strong, nonatomic) NSMutableArray *valueArray;//数据

@end

@implementation PersonalDataVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"个人资料";
    
    //添加导航 保存按钮
    [self addSaveBtnWithRightNavigationItem];
    
    //注册自定义cell
    [self.listTableView registerNib:[UINib nibWithNibName:@"PersonalDataCell"  bundle:nil] forCellReuseIdentifier:@"PersonalDataCell" ];
    [self.listTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [self.listTableView setBackgroundColor:[UIColor whiteColor]];
    
    self.dataArray = [NSMutableArray arrayWithObjects:@"头像",@"姓名：",@"微信号：",@"电话号码：",@"学号：",@"城市：",@"年级：",@"目前就读专业：",@"课程有效期：", nil];
     self.valueArray = [NSMutableArray arrayWithObjects:@" ",@"商学院",@"shangxueyuan",@"18502528415",@"YT02150438",@"陕西省西安市",@"大三",@"工商管理",@"2018.04.15~2019.05.15", nil];
}

-(void)addSaveBtnWithRightNavigationItem
{
    //添加保存按钮
    UIButton *saveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [saveBtn setFrame:CGRectMake(0, 0, 44, 44)];
    [saveBtn  setTitle:@"保存" forState:UIControlStateNormal];
    [saveBtn setTitleColor:[UIColor colorForHex:PINK_COCOR] forState:UIControlStateNormal];
    [saveBtn.titleLabel setFont:[UIFont systemFontOfSize:14.0]];
    
    [saveBtn addTarget:self action:@selector(saveBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithCustomView:saveBtn]];
}

-(void)saveBtnClicked:(UIButton *)sender
{
    [HUD showAlertWithTitle:DEFAULT_ALERT_MESSAGE];
    
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark *** tableView_delegate  ***
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    PersonalDataCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PersonalDataCell"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    [cell.contentView setBackgroundColor:[UIColor whiteColor]];
    
    if (indexPath.row == 0 )
    {
        [cell.dataImage setHidden:NO];
    }
    if (indexPath.row == 5)
    {
        [cell.dataImage setHidden:NO];
        [cell.dataImage setImage:[UIImage imageNamed:@"right_arrow"]];
        [cell.dataImage setContentMode:UIViewContentModeCenter];
    }
    
    [cell.dataType setText:[self.dataArray objectAtIndex:indexPath.row]];
    [cell.dataValue setText:[self.valueArray objectAtIndex:indexPath.row]];
    
    return cell;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return  [self.dataArray count];
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 48;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [HUD showAlertWithTitle:DEFAULT_ALERT_MESSAGE];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
